package com.hunttown.mes.rpc.domain.enums.company;

import java.util.HashMap;
import java.util.Map;

/**
 * 公司类型 枚举 1用车单位 2供应商 3修理厂 4油气站 5保险公司 6石油公司 7开票公司
 * created by wangjunfu on 2018/11/6
 */
public enum CompanyTypeEnum {
    CUSTOMER(1, "用车单位"),
    SUPPLY(2, "供应商"),
    REPAIRDEPOT(3, "修理厂"),
    GASSTATION(4, "油气站"),
    INS(5, "保险公司"),
    OILCOMPANY(6, "油气公司"),
    INVOICECOMPANY(7, "公司信息"),
    EQUIPCOMPANY(8, "设备厂家"),
    CUSTOM(9, "客户信息");

    private final int key;
    private final String value;

    CompanyTypeEnum(int key, String value) {
        this.key = key;
        this.value = value;
    }

    // 根据key获取枚举
    public static String getEnumByKey(int key) {
        String value = "";

        for (CompanyTypeEnum temp : CompanyTypeEnum.values()) {
            if (temp.getKey() == key) {
                value = temp.getValue();
            }
        }

        return value;
    }

    // 将枚举组成Map
    public static Map<Integer, String> getEnumList() {
        Map<Integer, String> map = new HashMap<>();

        for (CompanyTypeEnum temp : CompanyTypeEnum.values()) {
            map.put(temp.getKey(), temp.getValue());
        }

        return map;
    }

    public int getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }
}
